-- resist
-- created by panyl
-- 中毒

return {
    apply = function(prop, baseValue)
        -- 抗性必然大于0
        prop[3] = math.max(prop[3], 0);

        local v = math.modf(baseValue * prop[3] / 1000);

        return baseValue - v;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;
        local num = prop[3] / 10;

        if "attack" == prop[2] then
            desc = string.gsub(desc, "{0}", getLocStr("physical"));
        else
            desc = string.gsub(desc, "{0}", getLocStr("spell"));
        end

        desc = string.gsub(desc, "{1}", num);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end,

    title = function(prop)
        local str = "";
        if prop[2] == "attack" then
            str = getLocStr("physical_resistance");
        else
            str = getLocStr("spell_resistance");
        end

        return str;
    end
};